<include file="public/layout" />
<script type="text/javascript" src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>

<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <div class="subject">
        <h3>商品订单</h3>
        <h5>商城实物商品交易订单查询及管理</h5>
      </div>
    </div>
  </div>
  <!-- 操作说明 -->

  <div class="flexigrid">
    <div class="mDiv">
      <div class="ftitle">
        <h3>订单列表</h3>
        <h5>(共{$page->totalRows}条记录)</h5>
      </div>
      
      <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
	  <form class="navbar-form form-inline"  method="post" action="{:U('Admin/order/export_order')}"  name="search-form2" id="search-form2">  
	  		<input type="hidden" name="order_by" value="order_id">
            <input type="hidden" name="sort" value="desc">
            <input type="hidden" name="user_id" value="{$Request.param.user_id}">
            <input type="hidden" name="order_ids" value="">
            <!--用于查看结算统计 包含了哪些订单-->
            <input type="hidden" value="{$_GET['order_statis_id']}" name="order_statis_id" />                                    
     </form>
    </div>
<!--       <div><a href="{:U('Admin/order/export_buylist')}">导出</a></div>
 -->
    <div class="hDiv">
      <div class="hDivBox" id="ajax_return">
        <table cellspacing="0" cellpadding="0">

          <thead>
	        	<tr>

	              <th axis="col0">
	                <div style="width: 24px;"><i class="ico-check"></i></div>
	              </th>
                <th align="left" abbr="order_sn" axis="col3" class="">
                  <div style="text-align: left; width: 100px;" class="">商品编号</div>
                </th>
	              <th align="left" abbr="consignee" axis="col4" class="">
	                <div style="text-align: left; width: 140px;" class="">商品名称</div>
	              </th>
                
                <th align="center" abbr="article_show" axis="col5" class="">
                  <div style="text-align: center; width: 100px;" class="">商品型号</div>
                </th>               
	              <th align="center" abbr="article_show" axis="col5" class="">
	                <div style="text-align: center; width: 200px;" class="">商品规格</div>
	              </th>
                <th align="left" abbr="consignee" axis="col4" class="">
                  <div style="text-align: left; width: 100px;" class="">品牌</div>
                </th>                
                <th align="left" abbr="consignee" axis="col4" class="">
                  <div style="text-align: left; width: 140px;" class="">供应商</div>
                </th>
<!--                 <th align="left" abbr="consignee" axis="col4" class="">
                  <div style="text-align: left; width: 60px;" class="">产地</div>
                </th> -->
<!--                 <th align="left" abbr="consignee" axis="col4" class="">
                  <div style="text-align: left; width: 60px;" class="">单价</div>
                </th>   -->                                	              
                <th align="center" abbr="article_time" axis="col6" class="">
	                <div style="text-align: center; width: 40px;" class="">数量</div>
	              </th>
                <th align="center" abbr="article_time" axis="col6" class="">
                  <div style="text-align: center; width: 120px;" class="">院区</div>
                </th>
<!--                 <th align="center" abbr="article_time" axis="col6" class="">
                  <div style="text-align: center;" class="">地址</div>
                </th -->
	            </tr>
	          </thead>
        </table>
      </div>
    </div>
        <div class="tDiv">
      <if condition="$admin.role_id eq 6">
      <div class="tDiv2">
        <div class="fbutton"> 
          <a href="{:U('Admin/order/export_buylist')}">
              <div class="add" title="选定行数据导出excel文件,如果不选中行，将导出列表所有数据">
                <span><i class="fa fa-plus"></i>导出数据</span>
              </div>
            </a> 
          </div>

      </div>
      </if>
      <div style="clear:both"></div>
    </div>
    <div class="bDiv" style="height: auto;">
      <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
        
      </div>
      <div class="iDiv" style="display: none;"></div>
    </div>
    <!--分页位置--> 
   	</div>
</div>
<script type="text/javascript">

	 
    $(document).ready(function(){	
	   
		// 点击刷新数据
		$('.fa-refresh').click(function(){
			location.href = location.href;
		});
		
		ajax_get_table('',1);
		
		$('.ico-check ' , '.hDivBox').click(function(){
			$('tr' ,'.hDivBox').toggleClass('trSelected' , function(index,currentclass){
	    		var hasClass = $(this).hasClass('trSelected');
	    		$('tr' , '#flexigrid').each(function(){
	    			if(hasClass){
	    				$(this).addClass('trSelected');
	    			}else{
	    				$(this).removeClass('trSelected');
	    			}
	    		});  
	    	});
		});
		 
	});
    
    
  	//ajax 抓取页面
    function ajax_get_table(tab,page){
      // alert(tab);
        cur_page = page; //当前页面 保存为全局变量
            $.ajax({
                type : "POST",
                url:"/index.php/Admin/order/buylist_ajax/p/"+page,//+tab,
                data : {msg: tab},// 你的formid
                success: function(data){
                    $("#flexigrid").html('');
                    $("#flexigrid").append(data);
                    
                	// 表格行点击选中切换
            	    $('#flexigrid > table>tbody >tr').click(function(){
            		    $(this).toggleClass('trSelected');
            		});
                	 
                }
            });
    }
	
 // 点击排序
    function sort(field){
        $("input[name='order_by']").val(field);
        var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='sort']").val(v);
        ajax_get_table('search-form2',cur_page);
    }
	
	function exportReport(){
        var selected_ids = '';
        $('.trSelected' , '#flexigrid').each(function(i){
            selected_ids += $(this).data('order-id')+',';
        });
        if(selected_ids != ''){
            $('input[name="order_ids"]').val(selected_ids.substring(0,selected_ids.length-1));
        }
		$('#search-form2').submit();
	}
  
  function  allow(obj) {
    // alert($(obj).attr('data-url')); 
      $.ajax({
        type: 'post',
        url: $(obj).attr('data-url'),
        data: {status:1,order_id: $(obj).attr('data-id')},
        dataType: 'json',
        success: function (data){
          if (data.msg == 1) {
            $(obj).parent().parent().parent().remove();
          }
        },
        error:function(){
          alert('网络错误');
        }
      })
    }

  function  refuse(obj) {
    var ref = prompt('请填写拒绝原因')
      // alert(ref);
      if (ref !=null && ref !="") {
        $.ajax({
          type: 'post',
          url: $(obj).attr('data-url'),
          data: {order_id: $(obj).attr('data-id'),refuse_info: ref},
          dataType: 'json',
          success: function (data){
            if (data.msg == 1) {
              $(obj).parent().parent().parent().remove();
            }
          },
          error:function(){
            alert('网络错误');
          }
        })      
      };       
    }	

</script>
</body>
</html>